<?php

/**
 * OntoWiki table partial template
 *
 * @author  Norman Heino <norman.heino@gmail.com>
 * @author  Michael Haschke
 * @version $$
 */

?>
<table class="separated-vertical <?php echo $this->has('tableClass') ? $this->tableClass : '' ?>">
    <?php if ($this->has('caption')): ?>
        <caption><?php echo $this->caption ?></caption>
    <?php endif; ?>
    
    <?php if ($this->has('header')): ?>
        <tr>
            <?php foreach ($this->header as $headerField): ?>
                <th><?php echo $headerField ?></th>
            <?php endforeach; ?>
        </tr>
    <?php endif; ?>
    
    <?php $r = 0; ?>
    <?php foreach ($this->data as $row): ?>
        <tr<?php echo $this->has('rowClass') ? (' class="' . $this->rowClass . '"') : '' ?>>
            <?php $c = 0; ?>
            <?php foreach ($row as $field): ?>
                <td<?php echo $this->has('itemClass') ? (' class="' . $this->itemClass . '"') : '' ?>
                   id="<?php echo sprintf("r%d-c%d", $r, $c) ?>"><?php 
                    echo $this->escape($field) 
                ?></td>
                <?php $c++; ?>
            <?php endforeach; ?>
        </tr>
        <?php $r++; ?>
    <?php endforeach; ?>
</table>
